grammar MultiFar;

options {
  //k = 2;                           // two token lookahead
  output=AST;
  ASTLabelType=CommonTree;
}

@lexer::header{
package antlr.output; 

import com.oop.example.processing.ParseError;
}

@parser::header{
package antlr.output; 

import com.oop.example.processing.ParseError;
}

@lexer::members {
  @Override
  public void reportError(RecognitionException e) {
    throw new ParseError(e.charPositionInLine, "error");
  }
}

@parser::members {
  @Override
  public void reportError(RecognitionException e) {
    throw new ParseError(e.charPositionInLine, "error");
  }
}
prog : HEADER;
//DD : '?';
HEADER          : '<b style=\'color:aqua\'>' ('\u00a1'|'!'|PORTU_LETER|DOT)+ SUP? (COMMA WS TERE PORTU_LETER+ )? '</b>';
ALTERNAT_HEADER : '<b style=\'color:aqua\'>' ('\u00a1'|'!'|PORTU_LETER|DOT)+ SUP? (COMMA WS PORTU_LETER+ )? '</b>';
TRANSCRIPTION   : L_BRACKET (COMMA|'\u00E1'|'\u00ED'|'\u2019'|'<b>'|'</b>'|'a'..'z'|'\u00b4'|'\u03b8'|'\u03bb'|'\u0283'|':'|'\u0304'|'\u00f1'|L_PARENTHESIS|R_PARENTHESIS)+ R_BRACKET;
fragment 
DATE            : '1'..'2' '0'..'9' '0'..'9' '0'..'9';
fragment 
PORTU_LETER     : '\u0304'|'\u00d1'|'\u2019'|'A'..'Z'|'a'..'z'|'\u00d4'|'\u00f1'|'\u00C0'|'\u00E0'|'\u00C1'|'\u00E1'|'\u00C2'|'\u00E2'|'\u00C3'|'\u00E3'|'\u00C7'|'\u00E7'|'\u00C8'|'\u00E8'|'\u00C9'|'\u00E9'|'\u00CA'|'\u00EA'|'\u00CC'|'\u00EC'|'\u00CD'|'\u00ED'|'\u00CF'|'\u00EF'|'\u00D2'|'\u00F2'|'\u00D3'|'\u00F3'|'\u00D5'|'\u00F5'|'\u00D9'|'\u00F9'|'\u00DA'|'\u00FA'|'\u00DC'|'\u00FC'|'\u00AA'|'\u00BA'|'\u00F4';
REFERENCE       : '\u2192' (TERE|PORTU_LETER)+ '.'; 
fragment
ANY_CHAR        : '\u2019'|'\u00a1'|'\u00bf'|'0'..'9'|PORTU_LETER|COMMA|WS|TERE|L_PARENTHESIS|R_PARENTHESIS;
fragment
SUP             : '<sup>' '0'..'9' '</sup>';
EXAMPLE         : '<i>' EXAMPLE_HEADER (SLASH EXAMPLE_HEADER)* '</i>' WS SLASH EXAMPLE_BODY (SLASH EXAMPLE_BODY)* EXAMPLE_END;
FIXED_EXAMPLE   : '<b>' EXAMPLE_HEADER (SLASH EXAMPLE_HEADER)* '</b>'        EXAMPLE_BODY (SLASH EXAMPLE_BODY)* EXAMPLE_END;
NUM_FIXED_EXAMPLE: '<b>' EXAMPLE_HEADER COLON '</b>' (WS SUB_NUMERATION EXAMPLE_BODY EXAMPLE_END)+;
fragment
EXAMPLE_HEADER  : (ANY_CHAR|NO_CHAR|'!'|'?'|'"')+;
fragment
EXAMPLE_BODY    : (NO_CHAR|ANY_CHAR|'"'|LABEL|DOUBLESHARP|SHARP|SEMI)+;
fragment
EXAMPLE_END     : (DOT|'!'|'?');
REF_CLAS        : '@' '\u2192' .+ DOT;
//WORD_FORM       : '<b>' ('1'..'9') WS PORTU_LETER+ '</b>';
PORTU_WORD      : ITALIC_IN_SIMPLE|NOTCOMMENT|DATE|NO_CHAR|PORTU_LETER+ TERE? (DATE|PORTU_LETER+|NOTCOMMENT)* ('!'|'?')?;
NUMERATION      : '<b>' '@' ('1'..'9'|'10'|'11'|'12') '</b>';
SUB_NUMERATION  : 'a'..'x' ')';
TOCLASSIF       : '<CL/><b>'(PORTU_WORD|WS)+'</b>' WS LABEL (SHARP LABEL)* ;
//NUMERATION_L    : (LABEL (PLUS|COMMA WS|WS)?)* '<BSL/>';
//SUB_NUMERATION_L: (LABEL (PLUS|COMMA WS|WS)?)* '<BSSL/>';
LABEL 	       	: '<i>{' (PORTU_LETER|WS)+ '}</i>';
VEJA            : '\u2192'? ('Veja modelo'|'Veja nota'|'Ver nota') .* '.';
fragment
NOTCOMMENT      : L_PARENTHESIS (TERE|PORTU_LETER|WS|COMMA|'etc.')+ R_PARENTHESIS;
COMMENT         : '<i>' NOTCOMMENT '</i>';
SIN             : '<i>Sin:' WS (PORTU_LETER|COMMA|WS)+ DOT '</i>';
VAR             : '<i>Var:' WS (PORTU_LETER|COMMA|WS)+ DOT '</i>';
PART_IRREG      : '<i>Part irreg:</i>' (PORTU_LETER|COMMA|WS)+ DOT;
fragment
ITALIC_IN_SIMPLE: '@<i>' (ANY_CHAR|DOT|NO_CHAR)+ '</i>';
COMMENT_IN_SIMPLE: '^<i>' (ANY_CHAR|DOT|NO_CHAR)+ '</i>';
CUSTOM          : '<h1>' (ANY_CHAR|'!'|'?'|'<b>'|'</b>'|'<i>'|'</i>'|COLON|SEMI|SLASH|DOT|'"'|NO_CHAR)+ '</h1>';
HOMONYM         : '<homonym/>';
SIMPLE          : '~'.*'~';
fragment
NO_CHAR         : '@.'|'@,'|'@:'|'@-'|'@/'|'@;'|'@!'|'@?';
WS              : (' ') {$channel=HIDDEN;};
DOT             : '.';
L_TRIANGULAR    : '<';
R_TRIANGULAR    : '>';
L_PARENTHESIS   : '(';
R_PARENTHESIS   : ')';
L_BRACKET       : '[';
R_BRACKET       : ']';
PLUS            : '+';
COMMA           : ',';
fragment
TERE            : '-';
SHARP           : '#';
DOUBLESHARP     : '##';
STAR            : '*';
COLON           : ':';
SEMI            : ';';
PROC            : '%';
SLASH           : '/';
LONG_SLASH      : ' / ';

